package com.edu.medicalpro.kepuyemian;
import android.util.Log;
import android.view.View;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.edu.medicalpro.R;
import com.edu.medicalpro.activity.MainActivity;
import com.edu.medicalpro.base.BaseFragment;
import com.edu.medicalpro.retrofit.Healthrequest;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
public class KepuyemianFragment extends BaseFragment {
    public  static Healthrequest healthrequest;
    @Override
    protected void initView(View rootView) {
        ((MainActivity)requireActivity()).getViewModel().getNewstype(requireActivity(), new Observer<String>() {
            @Override
            public void onChanged(String s) {
                Log.d("111",s);
            }
        });
        //绑定recyclerView
        RecyclerView recyclerView=rootView.findViewById(R.id.recycler_view);
        //创建RecyclerViewAdapter
      //  RecyclerViewAdapter adapter=new RecyclerViewAdapter(requireActivity());
        LinearLayoutManager llg=new LinearLayoutManager(requireActivity());
        llg.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(llg);
        //初始化Retrofit
        Retrofit retrofit=new Retrofit.Builder()
                //主机地址
                .baseUrl("http://apis.juhe.cn")
                //添加GSON转换插件
                //配置Retrofit内部的OKHttp内核
                .addConverterFactory(GsonConverterFactory.create())
                //添加Rxjava插件
                .addCallAdapterFactory(RxJava3CallAdapterFactory.create())
                .build();
        //注册Retrofit接口
        healthrequest=retrofit.create(Healthrequest.class);
//        List<Data> dataList = new ArrayList<>();
//        for (int i = 0; i < 5; i++) {
//            Data data = new Data();
//            data.setId(R.mipmap.ic_launcher);
//            data.setName("商品名称" + i);
//            dataList.add(data);
//        }
//        MyAdapter adapter=new MyAdapter( requireActivity());
//        adapter.setDataList(dataList);
//        recyclerView.setAdapter(adapter);
    }
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_kepuyemian;
    }
    @Override
    protected void initData() {

    }
}